#include <bits/stdc++.h>

#include <atcoder/all>
#define LL long long
using namespace std;
using namespace atcoder;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  vector<int> cnt;

  cin >> s;
  cnt.resize(s.size(), 1);
  for (int i = s.size() - 2; i >= 0; i--) {
    if (s[i] == s[i + 1]) {
      cnt[i] = cnt[i + 1] + 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (i + cnt[i] < s.size() && s[i] + 1 == s[i + cnt[i]] && cnt[i + cnt[i]] >= cnt[i]) {
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}